{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6aad3bf5",
   "metadata": {},
   "source": [
    "# date， time 相关\n",
    "测试通过后需要分流到datetime.date类 和datetime.datetime等单独的ipynb上去"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "465499b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "from dateutil.relativedelta import relativedelta\n",
    "from datetime import datetime, date, timedelta"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "38207634",
   "metadata": {},
   "source": [
    "relativedelta V.S. timedelta (https://blog.csdn.net/u010569893/article/details/103880503)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "20fb0892",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2022-03-22 10:14:16.652508\n"
     ]
    }
   ],
   "source": [
    "now_date = datetime.now()\n",
    "print(now_date + relativedelta(months=1))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0abb08f2",
   "metadata": {},
   "source": [
    "当地时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "32928577",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2022, 2, 22, 10, 14, 16, 652508)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "now_date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c28bbffa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(now_date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8bd1c2ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1645496056.652508"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "now_date.timestamp()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9f18a151",
   "metadata": {},
   "source": [
    "UTC-0 时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "cc711d5c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2022, 2, 22, 2, 14, 16, 652508)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.utcfromtimestamp(now_date.timestamp())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "da276603",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
